<template>
    <el-card class="m_t_b_10px xd-LearningHome-PolicyDetail" shadow="hover">
        <div slot="header" class="clearfix">
            <p class="text_size_30">
                <b v-text="detail.analysisTitle || detail.policyTitle"></b>
            </p>
            <div class="text_color_999999 text_size_7 desc">
                <!-- <span>文件级别：{{detail.fileTypeName}}</span> -->
                <span>主题类型：{{detail.themeTypeName}}</span>
                <span v-if="detail.analysisTitle">解读政策：{{detail.policyTitle}}</span>
                <span>发文日期：{{detail.createTime}}</span>
            </div>
        </div>
        <pre v-html="detail.analysisContent || detail.policyContent"></pre>
        <div slot="header" class="clearfix">
            <div v-for="(p,index) in detail.policyEnclosureList" v-bind:key="index" style="line-height: 25px;" class="text_size_7">
                <a v-show="p.fileName" class="affix" title="点击下载" target="_blank" @click="registerDownnum(p)" :href="p.filePath" style="text-decoration: none;color:#006756;">【{{p.fileName}}】</a>
                <span class="text_color_999999 desc">下载 {{p.downnum}} 次</span>
            </div>
            <div v-for="(p,index) in detail.policyAnalysisEnclosureList" v-bind:key="index" style="line-height: 25px;" class="text_size_7">
                <a v-show="p.fileName" class="affix" title="点击下载" target="_blank" @click="registerDownnum(p)" :href="p.filePath" style="text-decoration: none;color:#006756;">【{{p.fileName}}】</a>
                <span class="text_color_999999 desc">下载 {{p.downnum}} 次</span>
            </div>
        </div>
    </el-card>
</template>
<script>
export default {
    name: 'PolicyDetail',
    data() {
        return {
            detail: {}
        };
    },
    mounted() {
        this.$store.commit('updateActiveMenu', '/LearningHome/PolicyInterpretation');
        var id = this.$route.query.id;
        var tag = this.$route.query.tag;
        this.getDetail(id, tag);
    },
    methods: {
        getDetail(id, tag) {
            var params = {};
            var api = utils.api.policyInfo.policyNewsDetail;
            if (tag === '1') {
                params.policyId = id;
            } else {
                api = utils.api.policyInfo.policyDetail;
                params.id = id;
            }
            utils.post(api, params, res => {
                if (res.success) {
                    this.detail = res.data;
                }
            });
        },
        registerDownnum(obj) {
            var api = utils.api.policyInfo.registerDownnum + '/' + obj.id;
            utils.post(api, {}, res => {
                if (res.success) {
                    obj.downnum = obj.downnum + 1;
                }
            });
        }
    }
};
</script>
<style lang="less">
.xd-LearningHome-PolicyDetail {
    .el-card__header {
        padding-top: 0px;
    }
    .clearfix {
        text-align: center;
        margin-bottom: 13px;
        .desc {
            span {
                margin-right: 25px;
            }
        }
    }
}
</style>